<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - rsignaler_extension.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2006  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_RSIGNALER_EXTENSIOn_
<font color='#0000FF'>#define</font> DLIB_RSIGNALER_EXTENSIOn_ 

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='rsignaler_extension_abstract.h.html'>rsignaler_extension_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='rmutex_extension.h.html'>rmutex_extension.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='rsignaler'></a>rsignaler</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <b><a name='rsignaler'></a>rsignaler</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> rmutex<font color='#5555FF'>&amp;</font> associated_mutex
        <font face='Lucida Console'>)</font> : 
            assoc_mutex<font face='Lucida Console'>(</font>associated_mutex<font face='Lucida Console'>)</font>,
            s<font face='Lucida Console'>(</font>m<font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>

        ~<b><a name='rsignaler'></a>rsignaler</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='wait'></a>wait</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            m.<font color='#BB00BB'>lock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> lock_count <font color='#5555FF'>=</font> assoc_mutex.<font color='#BB00BB'>lock_count</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            assoc_mutex.<font color='#BB00BB'>unlock</font><font face='Lucida Console'>(</font>lock_count<font face='Lucida Console'>)</font>;
            s.<font color='#BB00BB'>wait</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            m.<font color='#BB00BB'>unlock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            assoc_mutex.<font color='#BB00BB'>lock</font><font face='Lucida Console'>(</font>lock_count<font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'><u>bool</u></font> <b><a name='wait_or_timeout'></a>wait_or_timeout</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> milliseconds
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            m.<font color='#BB00BB'>lock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> lock_count <font color='#5555FF'>=</font> assoc_mutex.<font color='#BB00BB'>lock_count</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            assoc_mutex.<font color='#BB00BB'>unlock</font><font face='Lucida Console'>(</font>lock_count<font face='Lucida Console'>)</font>;
            <font color='#0000FF'><u>bool</u></font> res <font color='#5555FF'>=</font> s.<font color='#BB00BB'>wait_or_timeout</font><font face='Lucida Console'>(</font>milliseconds<font face='Lucida Console'>)</font>;
            m.<font color='#BB00BB'>unlock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            assoc_mutex.<font color='#BB00BB'>lock</font><font face='Lucida Console'>(</font>lock_count<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> res;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='signal'></a>signal</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> 
            m.<font color='#BB00BB'>lock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            s.<font color='#BB00BB'>signal</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; 
            m.<font color='#BB00BB'>unlock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='broadcast'></a>broadcast</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> 
            m.<font color='#BB00BB'>lock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            s.<font color='#BB00BB'>broadcast</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; 
            m.<font color='#BB00BB'>unlock</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>const</font> rmutex<font color='#5555FF'>&amp;</font> <b><a name='get_mutex'></a>get_mutex</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> assoc_mutex; <b>}</b>

    <font color='#0000FF'>private</font>:

        <font color='#0000FF'>const</font> rmutex<font color='#5555FF'>&amp;</font> assoc_mutex;
        mutex m;
        signaler s;


        <font color='#009900'>// restricted functions
</font>        <b><a name='rsignaler'></a>rsignaler</b><font face='Lucida Console'>(</font>rsignaler<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;        <font color='#009900'>// copy constructor
</font>        rsignaler<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>rsignaler<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;    <font color='#009900'>// assignment operator
</font>    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_RSIGNALER_EXTENSIOn_ 
</font>



</pre></body></html>